﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace homeworkhero
{
    public class AnimationSet
    {
        Animation[] animations;
        int currAnimation;

        public AnimationSet(Animation[] anims) {
            animations = anims;
            currAnimation = 0;
        }

        public void setAnimation(String animName) {
            for(int i=0;i<animations.Length;i++) {
                if(animations[i].getName().Equals(animName)) {
                    currAnimation = i;
                    return;
                }
            }

            //throw new Exception("Animation name not found: "+animName);
        }

        public Animation getCurrAnimation() {
            return animations[currAnimation];
        }

        public Animation getAnimation(String animName) {
            for(int i=0;i<animations.Length;i++) {
                if(animations[i].getName().Equals(animName)) {
                    return animations[i];
                }
            }

            throw new Exception("Animation name not found: "+animName);
        }

        public Animation getAnimation(int animNum) {
            if (animNum >= animations.Length)
                return null;
                //throw new Exception("getAnimation given too large animNum");

            return animations[animNum];
        }

        public Vector2 getDimensions() {
            return animations[0].getDimensions();
        }

        public AnimationSet copy() {
            Animation[] anims = new Animation[animations.Length];
            for(int i=0;i<animations.Length;i++) {
                anims[i] = animations[i].copy();
            }
            return new AnimationSet(anims);
        }
    }
}
